<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
	<META HTTP-EQUIV="pragma" CONTENT="no-cache">
	<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
	<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
	<META HTTP-EQUIV="expires" CONTENT="0">
	<script language="javascript" src="./dp.SyntaxHighlighter/Scripts/shCore.js"></script>
<TITLE> New Document </TITLE>
<script language="javascript">
var oEditor = window.parent.InnerDialogLoaded() ;
var FCKLang = oEditor.FCKLang ;
var FCKHighLighter = oEditor.FCKHighLighter ;

//var SCRIPT_PATH	  = FCKConfig.PluginsPath + "highlighter/dp.SyntaxHighlighter/Scripts/";
var SCRIPT_PATH	  = "./dp.SyntaxHighlighter/Scripts/";
var PREFIX 		  = "shBrush";
var POSTFIX 	  = ".js";
var TypeMapper = {
	"php"        : PREFIX + "Php" + POSTFIX , 
	"javascript" : PREFIX + "JScript" + POSTFIX ,
	"java" 		 : PREFIX + "Java" + POSTFIX ,
	"xml"  		 : PREFIX + "Xml" + POSTFIX ,
	"html"  	 : PREFIX + "Xml" + POSTFIX ,
	"cpp"  		 : PREFIX + "Cpp" + POSTFIX ,
	"c#" 		 : PREFIX + "CSharp" + POSTFIX ,
	"css" 		 : PREFIX + "Css" + POSTFIX ,
	"delphi" 	 : PREFIX + "Delphi" + POSTFIX ,
	"python" 	 : PREFIX + "Python" + POSTFIX ,
	"ruby" 		 : PREFIX + "Ruby" + POSTFIX ,
	"sql" 		 : PREFIX + "Sql" + POSTFIX ,
	"vb" 		 : PREFIX + "Vb" + POSTFIX 
};
window.onload = function () {
	// First of all, translate the dialog box texts
	oEditor.FCKLanguageManager.TranslatePage( document ) ;
	// Show the "Ok" button.
	window.parent.SetOkButton( true ) ;	

	LoadSelected();
}
function Ok()
{
	if(document.getElementById("codeType").value.length == 0)
	{
		alert("请选择一种语言");
		return false; 
	}	
	if(document.getElementById("code").value.length==0)
	{
		alert("代码不能为空");
		return false;
	}	
	//dp.SyntaxHighlighter.ClipboardSwf = SCRIPT_PATH + 'clipboard.swf';
	var result = dp.SyntaxHighlighter.HighlightAll('code',1,0,0,1);
	var str = "";
	for(key in result)
	{
		str += "<div class='dp-highlighter'>";
		str += result[key][0];
		str += "</div>";
		if ( !oEditor.FCKBrowserInfo.IsIE )
		{
			str += "<div class='";
			str += result[key][2];
			str += "' style='display:none'>";
			str += result[key][1].replace("<" , "&lt;");
			str += "</div>";
		}
	}
	FCKHighLighter.Add( str ) ;
	return true ;
}
function createScript( type )
{
	var oScript = document.createElement("script");
	var src = TypeMapper[type]; 
	oScript.LANGUAGE  = "javascript";
	oScript.TYPE = "text/javascript";
	oScript.src = SCRIPT_PATH + src;
	document.body.appendChild( oScript );
}
function setCodeType( codeType )
{
	document.getElementById("code").className = codeType;
	createScript(codeType);
}
var eSelected = oEditor.FCKSelection.GetSelectedElement() ;
function LoadSelected()
{
	if ( !eSelected )
		return ;

	if ( eSelected.tagName == 'DIV' && eSelected._FCKhighLighter )
	{
		var language    = eSelected.nextSibling.className;
		var codeTypeNum = document.getElementById("codeType").options.length;
		document.getElementById("code").className = language;
		createScript(language);
		for(var i=0;i<codeTypeNum;i++)
		{
			if(document.getElementById("codeType").options[i].value == language)
			{
				document.getElementById("codeType").options[i].selected = true;
			}
		}
		var codeContent = eSelected.nextSibling.innerHTML;
		document.getElementById('code').value = codeContent.replace("&lt;" , "<");
	}
	else eSelected == null ;
}
</script>
</HEAD>

<BODY>
	<select id="codeType" onchange="setCodeType(this.value);">
	<option value="">请选择一样语言</option>
	<option value="php">php</option>
	<option value="javascript">javascript</option>
	<option value="xml">xml</option>
	<option value="css">css</option>
	<option value="c#">c#</option>
	<option value="cpp">c++</option>
	<option value="delphi">delphi</option>
	<option value="java">java</option>
	<option value="python">python</option>
	<option value="ruby">ruby</option>
	<option value="sql">sql</option>
	<option value="vb">vb</option>
	</select>	
<textarea cols='95' class="" rows='25' name="code" id="code">
</textarea>
</BODY>
</HTML>
